#include <iostream>
#include <string>

// 定义一个抽象类
class Shape {
public:
    // 纯虚函数，子类必须实现
    virtual void draw() = 0;

    // 非虚函数，子类可以选择性地重写
    void info() {
        std::cout << "This is a shape." << std::endl;
    }
};

// 继承自 Shape 的子类 Circle
class Circle : public Shape {
public:
    void draw() override {
        std::cout << "Drawing a circle." << std::endl;
    }
};

// 继承自 Shape 的子类 Square
class Square : public Shape {
public:
    void draw() override {
        std::cout << "Drawing a square." << std::endl;
    }
};

int main() {
    // 创建 Circle 和 Square 的实例
    Shape* circle = new Circle();
    Shape* square = new Square();

    // 调用 draw 方法
    circle->draw(); // 输出: Drawing a circle.
    square->draw(); // 输出: Drawing a square.

    // 调用 info 方法
    circle->info(); // 输出: This is a shape.
    square->info(); // 输出: This is a shape.

    // 释放内存
    delete circle;
    delete square;

    return 0;
}
